
<template>
    <div>
                <h1>添加模板</h1>
            <div class="con">
            <div class="text">
                <span>服务名称</span>
                <input type="text" v-model="name">

            </div>
            <div class="text">
                <span>图标</span>
                <input type="file" id="file">

            </div>
            <div class="text">   
                <span>等级</span>         
                <select v-model="value">
                    <option value="1">联合创始人</option>
                    <option value="2">执行董事</option>
                    <option value="3">合伙人</option>
                    <option value="4">钻石代理</option>
                </select>
            </div>
            <span @click="ok">
                <Button type="primary">保存</Button>
            </span>
                
            </div>
    </div>
</template>
<script>
export default {
    data() {
        return {
            name:'',
            value:''
        };
    },
    mounted() {
        let mid = localStorage.getItem("mid");
        if (mid == 'undefined' || mid == ''){
            alert("您还没有登陆");
            this.$router.push("admin");
            return;
        }
        if (mid.indexOf('2') < 0){
            alert("您没有权限");
            return;
        }
    },
    methods: {
        ok(){
            alert(this.value);
            var param = new FormData();
            param.append("name", this.name);
            param.append("file", document.getElementById("file").files[0]);
            param.append("level", this.value);
            let qs = require('qs');
            this.axios({
                method: "post",
                url: `${this.adminUrl}/insertTemplet`,
                //url: `${this.siteUrl}/getInvitation`,
                data: param
                }).then(response => {
                    if ((response.data.result == 200)) {
                       alert("添加成功");
                    }else{
                        alert("请求失败");
                    }
                }).catch(err =>{
                    console.log(err);
            });
        }
    }
};
</script>

   



<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1 {
    margin-bottom: 20px;
    margin-top:20px;
}
button {
    margin-top: 50px;
}
span{
    display: inline-block;
    width: 100px;
    font-size: 16px;
}

</style>
